#include "Runnable.h"

Runnable::Runnable () : running(false), thread(0), threadID(0)
{
}

bool Runnable::startRunning ()
{
	thread = CreateThread(0, 0, threadEntryPoint, this, 0, &threadID);

	if (thread != NULL)
		return true;

	return false;
}

bool Runnable::isRunning ()
{
	return running;
}

void Runnable::stopRunning ()
{
	CloseHandle(thread);
}

void Runnable::run ()
{
}

DWORD WINAPI threadEntryPoint (LPVOID args)
{
	Runnable * runnable = (Runnable *) args;

	runnable->running = true;
	runnable->run();
	runnable->running = false;

	return 0;
}